/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._4Enumerate
 * @File : Q0788.java
 * @Author : WangRuoyu
 * @Date 2023/3/15 23:34
 */

package acwing._2LanQiao._4Enumerate;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._4Enumerate
 * @File : Q0788.java
 * @Author : WangRuoyu
 * @Date 2023/3/15 23:34
 */

public class Q0788 {

    static int[] tmp;
    static long res = 0;

    static void mergeSort(int[] q, int l, int r) {
        if (l >= r) {
            return;
        }
        int mid = (l + r) / 2;
        mergeSort(q, l, mid);
        mergeSort(q, mid + 1, r);

        int i = l;
        int j = mid + 1;
        int count = 0;

        while (i <= mid && j <= r) {
            if (q[i] <= q[j]) {
                tmp[count++] = q[i++];
            } else {
                tmp[count++] = q[j++];
                res += (mid - i + 1);
            }
        }
        while (i <= mid) {
            tmp[count++] = q[i++];
        }
        while (j <= r) {
            tmp[count++] = q[j++];
        }
        for (int k = 0; k < count; k++) {
            q[l + k] = tmp[k];
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");

        int n = Integer.parseInt(words[0]);
        int[] d = new int[n];
        tmp = new int[n + 10];

        words = br.readLine().split(" ");
        for (int i = 0; i < d.length; i++) {
            d[i] = Integer.parseInt(words[i]);
        }

        mergeSort(d, 0, n - 1);

        System.out.println(res);
    }
}
